<#macro gridBtns id btns urls options>
    <@buttonForGridTag btns=btns urls=urls options=options>
    <div id="${id}">
        <#if btnMap??&&(btnMap?size>0)>
            <#list btnMap?keys as btn>
                <#if btn=='upload'>
                    <a options='${btnMap[btn].options!""}' class="easyui-linkbutton jr-grid-upload"
                       data-options="iconCls:'icon-${btnMap[btn].icon}',plain:true"
                       style="position: relative;"><span
                            id="${id}Picker"
                            class="jr-upload"
                            server="<#if btnMap[btn].url?index_of('?')!=-1>${btnMap[btn].url}&mid=${menuDetail.id}<#else>${btnMap[btn].url}?mid=${menuDetail.id}</#if>"><@spring.message "${btnMap[btn].name}" /></span></a>
                <#else>
                    <a options='${btnMap[btn].options!""}'
                       url="<#if btnMap[btn].url?index_of('?')!=-1>${btnMap[btn].url}&mid=${menuDetail.id}<#else>${btnMap[btn].url}?mid=${menuDetail.id}</#if>"
                       href="javascript:void(0);"
                       class="easyui-linkbutton jr-${btn}"
                       data-options="iconCls:'icon-${btnMap[btn].icon}',plain:true"><@spring.message "${btnMap[btn].name}" /></a>
                </#if>
            </#list>
        </#if>
    </div>
    </@buttonForGridTag>
</#macro>

<#macro editBtns btns>
    <@buttonForEditTag btns=btns>
    <div class="buttonForEdit">
        <#if btnMap??&&(btnMap?size>0)>
            <#list btnMap?keys as btn>
                <a href="javascript:void(0);" class="easyui-linkbutton jr-edit-${btn}"
                   data-options="iconCls:'icon-${btnMap[btn].icon}',plain:false"><@spring.message "${btnMap[btn].name}" /></a>
            </#list>
        </#if>
    </div>
    </@buttonForEditTag>
</#macro>

<#macro gridCons gridId forms>
    <@conditionForGridTag gridId=gridId forms=forms>
    <div id="${gridId}-cons" class="easyui-dialog" title="<@spring.message '条件查询' />" data-options="
                    iconCls: 'icon-save',
                    width:600,
                    closed:true,
                    top:150,
                    buttons: [{
                        text:'<@spring.message '检索' />',
                        handler:function(){
                            conditionSearch('${gridId}');
                        }
                    }]
                ">
        <#if forms??>
            <div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <div class="panel-body">
                            <form class="form-horizontal" role="form">
                                <#list forms as f>
                                    <#if f.type=='text'>
                                        <div class="form-group">
                                            <label class="control-label col-sm-2"><@spring.message "${f.text!''}" /></label>

                                            <div class="col-sm-10">
                                                <input type="text" class="form-control" name="search.${f.op}.${f.field}"
                                                       placeholder="<#if f.tip??&&f.tip!=''><@spring.message "${f.tip!''}" /></#if>"/>
                                            </div>
                                        </div>
                                    <#elseif f.type=='select'>
                                        <div class="form-group">
                                            <label class="control-label col-sm-2"><@spring.message "${f.text!''}" /></label>

                                            <div class="col-sm-10">
                                                <input type="text" class="form-control easyui-combobox"
                                                       name="search.${f.op}.${f.field}"
                                                       placeholder="<#if f.tip??&&f.tip!=''><@spring.message "${f.tip!''}" /></#if>"
                                                       data-options="valueField:'id',textField:'text',url:'${f.paramUrl!''}',width:430"/>
                                            </div>
                                        </div>
                                    <#elseif f.type=='tree'>
                                        <div class="form-group">
                                            <label class="control-label col-sm-2"><@spring.message "${f.text!''}" /></label>

                                            <div class="col-sm-10">
                                                <input type="text" class="form-control easyui-combotree"
                                                       name="search.${f.op}.${f.field}"
                                                       placeholder="<#if f.tip??&&f.tip!=''><@spring.message "${f.tip!''}" /></#if>"
                                                       data-options="width:430"/>
                                            </div>
                                        </div>
                                    <#elseif f.type=='date'>
                                        <#if f.op=='between'>
                                            <div class="form-group">
                                                <label class="control-label col-sm-2"><@spring.message "${f.text!''}" /></label>

                                                <div class="col-sm-4">
                                                    <input type="text" class="form-control easyui-datebox"
                                                           name="search.between.start.${f.field}"
                                                           placeholder="<#if f.tip??&&f.tip!=''><@spring.message "${f.tip!''}" /></#if>"
                                                           data-options="width:150"/>
                                                </div>
                                                <label class="control-label col-sm-2"
                                                       style="text-align: center;"><@spring.message '至' /></label>

                                                <div class="col-sm-4">
                                                    <input type="text" class="form-control easyui-datebox"
                                                           name="search.between.end.${f.field}"
                                                           placeholder="<#if f.tip??&&f.tip!=''><@spring.message "${f.tip!''}" /></#if>"
                                                           data-options="width:150"/>
                                                </div>
                                            </div>
                                        <#else>
                                            <div class="form-group">
                                                <label class="control-label col-sm-2"><@spring.message "${f.text!''}" /></label>

                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control easyui-datebox"
                                                           name="search.${f.op}.${f.field}"
                                                           placeholder="<#if f.tip??&&f.tip!=''><@spring.message "${f.tip!''}" /></#if>"
                                                           data-options="width:430"/>
                                                </div>
                                            </div>
                                        </#if>
                                    </#if>
                                </#list>
                            </form>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        </#if>
    </@conditionForGridTag>
</#macro>

<#macro editForm forms formId action>
    <@formForEditTag forms=forms formId=formId action=action>
    <section class="jr-edit-top">
    <div class="row">
    <div class="col-sm-12">
    <section class="panel">
    <div class="panel-body">
        <#if forms??&&(forms?size>0)>
            <form id="${formId!'jr-form'}" action="${action!'save'}" method="post">
                <input type="hidden" name="id" id="id" value="${obj.id}"/>

                <div class="panel-body">
                    <div class="row">
                        <#list forms as f>
                            <#if f.type=='placeholder'>
                                <div class="form-group col-md-${f.col!'4'} jr-form-group">
                                    &nbsp;
                                </div>
                            <#elseif f.type=='hidden'>
                                <input type="hidden" name="${f.field}" value="${obj[f.field]}"/>
                            <#elseif f.type=='empty'>
                                <div class="form-group col-md-${f.col!'4'} jr-form-group">
                                    &nbsp;
                                </div>
                            <#else>
                                <div class="form-group col-md-${f.col!'4'} <#if f.type!='editor'&&f.type!='single-image'&&f.type!='textarea'>jr-form-group</#if>">
                                    <label for="${f.field}"><@spring.message "${f.text!''}" />：</label>

                                    <div>
                                        <#if f.type=='editor'>
                                            <textarea id="${f.field}" name="${f.field}"
                                                      style="width: 100%;height: 240px;">${obj[f.field]}</textarea>
                                            <script type="text/javascript">
                                                $(function () {
                                                    var ue_${f.field} = UE.getEditor('${f.field}');
                                                });
                                            </script>
                                        <#elseif f.type=='single-image'>
                                            <div style="float: left;">
                                                <#if obj[f.field]??>
                                                    <img id="${f.field}Img"
                                                         default="<@spring.url '/admin/resources/images/nopic.jpg' />"
                                                         style="max-width:180px;max-height:120px;"
                                                         src="${obj[f.field]}"/>
                                                <#else>
                                                    <img id="${f.field}Img"
                                                         default="<@spring.url '/admin/resources/images/nopic.jpg' />"
                                                         style="max-width:180px;max-height:120px;"
                                                         src="<@spring.url '/admin/resources/images/nopic.jpg' />"/>
                                                </#if>
                                            </div>
                                            <div style="float: left;margin-left: 10px;">
                                                <div style="float: left;">
                                                    <div class="btns">
                                                        <div id="${f.field}Picker"
                                                             server="<@spring.url '/admin/plugin/common-resource/upload' />"
                                                             class="jr-upload"><@spring.message '快速上传' />
                                                        </div>
                                                        <script type="text/javascript">
                                                            function jr${f.field}PickerUploadSuccess(file, rs) {
                                                                $("#${f.field}").val("<@spring.url '' />" + rs.output.filePath);
                                                                $("#${f.field}Img").attr("src", "<@spring.url '' />" + rs.output.filePath);
                                                            }
                                                        </script>
                                                    </div>
                                                </div>
                                                <div style="float: left;margin: 0 0 0 5px;">
                                                    <button class="btn btn-primary"
                                                            type="button"><@spring.message '美图上传' /></button>
                                                </div>
                                                <div style="float: left;margin: 0 0 0 5px;padding-top: 5px;"><label
                                                        for="${f.field}_isCompress"><@spring.message '图片是否开启压缩' /></label><input
                                                        style="margin-left: 5px;vertical-align:-2px;" type="checkbox"
                                                        id="${f.field}_isCompress"/></div>
                                                <div style="margin: 5px;clear: both;"></div>
                                                <div style="float: left;">
                                                    <button class="btn btn-primary jr-upload-senior"
                                                            server="<@spring.url '/admin/plugin/common-resource/list' />?mid=${menuDetail.id}&fun=jr${f.field}CallBack&singleSelect=true"
                                                            type="button"><@spring.message '高级上传' />
                                                    </button>
                                                    <script type="text/javascript">
                                                        function jr${f.field}CallBack(files, win) {
                                                            if (null != files && files.length == 1) {
                                                                var rs = {};
                                                                rs.output = files[0];
                                                                jr${f.field}PickerUploadSuccess(null, rs);
                                                                win.close();
                                                            }
                                                        }
                                                    </script>
                                                </div>
                                                <div style="float: left;margin: 0 0 0 5px;">
                                                    <button class="btn btn-danger jr-upload-delete"
                                                            type="button"><@spring.message '删除图片' />
                                                    </button>
                                                </div>
                                                <div style="float: left;margin: 0 0 0 5px;padding-top: 5px;"><label
                                                        for="isWatermark"><@spring.message '图片是否添加水印' /></label><input
                                                        style="margin-left: 5px;vertical-align:-2px;"
                                                        type="checkbox"
                                                        id="${f.field}_isWatermark"/></div>
                                            </div>
                                            <div style="clear: left;"></div>
                                            <input type="hidden" class="jr-upload-img" name="${f.field}"
                                                   id="${f.field}"/>
                                        <#elseif f.type=='select'>
                                            <#if f.no??&&f.no!=''>
                                                <#if f.options??&&f.options!=''>
                                                    <input style="width: 100%;" class="easyui-combobox" id="${f.field}"
                                                           name="${f.field}"
                                                           data-options="url:'<@spring.url '/admin/plugin/common-param/params?no=${f.no}' />',editable:false,${f.options!''}"
                                                           value="${obj[f.field]}"/>
                                                <#else>
                                                    <input style="width: 100%;" class="easyui-combobox" id="${f.field}"
                                                           name="${f.field}"
                                                           data-options="editable:false,textField:'name',valueField:'id',url:'<@spring.url '/admin/plugin/common-param/params?no=${f.no}' />'"
                                                           value="${obj[f.field]}"/>
                                                </#if>
                                            <#elseif f.websiteNo??&&f.websiteNo!=''>
                                                <#if f.options??&&f.options!=''>
                                                    <input style="width: 100%;" class="easyui-combobox" id="${f.field}"
                                                           name="${f.field}"
                                                           data-options='${f.options}'
                                                           value="${obj[f.field]}"/>
                                                <#else>
                                                    <input style="width: 100%;" class="easyui-combobox" id="${f.field}"
                                                           name="${f.field}"
                                                           data-options='editable:false,textField:"name",valueField:"id",url:"<@spring.url '/admin/plugin/common-website-param/params?no=${f.no}' />"'
                                                           value="${obj[f.field]}"/>
                                                </#if>
                                            <#else>
                                                <input style="width: 100%;" class="easyui-combobox" id="${f.field}"
                                                       name="${f.field}"
                                                       data-options="${f.options!''}" value="${obj[f.field]}"/>
                                            </#if>

                                        <#elseif f.type=='number'>
                                            <input style="width: 100%;" class="easyui-numberbox" name="${f.field}"
                                                   id="${f.field}" data-options="${f.options!''}"
                                                   value="${obj[f.field]}"/>
                                        <#elseif f.type=='password'>
                                            <input style="width: 100%;" class="easyui-passwordbox" name="${f.field}"
                                                   id="${f.field}" data-options="${f.options!''}"
                                                   value="${obj[f.field]}"/>
                                        <#elseif f.type=='date'>
                                            <input style="width: 100%;" class="easyui-datebox" name="${f.field}"
                                                   id="${f.field}" data-options="${f.options!''}"
                                                   value="${obj[f.field]?string('yyyy-MM-dd')}"/>
                                        <#elseif f.type=='datetime'>
                                            <input style="width: 100%;" class="easyui-datetimebox" name="${f.field}"
                                                   id="${f.field}" data-options="${f.options!''}"
                                                   value="${obj[f.field]?string('yyyy-MM-dd HH:mm:ss')}"/>
                                        <#elseif f.type=='treebox'>
                                            <input style="width: 100%;" class="easyui-combotree" id="${f.field}"
                                                   name="${f.field}"
                                                   data-options="${f.options!''}" value="${obj[f.field]}"/>
                                        <#elseif f.type=='textarea'>
                                            <#if f.options??&&f.options!=''>
                                                <textarea style="width: 100%;" class="easyui-textbox" name="${f.field}"
                                                       id="${f.field}" data-options="${f.options!''},multiline:true"
                                                >${obj[f.field]}</textarea>
                                            <#else >
                                                <textarea style="width: 100%;" class="easyui-textbox" name="${f.field}"
                                                       id="${f.field}" data-options="multiline:true"
                                                >${obj[f.field]}</textarea>
                                            </#if>
                                        <#else>
                                            <input style="width: 100%;" class="easyui-textbox form-control"
                                                   id="${f.field}"
                                                   name="${f.field}"
                                                   data-options="${f.options!''}" value="${obj[f.field]}"/>
                                        </#if>
                                        <#if f.bind??&&f.bind==false>
                                        <#else>
                                            <@spring.bind path="obj.${f.field}" />
                                        </#if>
                                    </div>
                                </div>
                            </#if>
                        </#list>
                    </div>
                </div>
            </form>
        </#if>
    </@formForEditTag>
</div>
</section>
</div>
</div>
</section>
</#macro>

<#macro scripts end>
    <@scriptForAllTag end=end>
    <script type="text/javascript" src="<@spring.url '/admin${scriptUrl}' />"></script>
    </@scriptForAllTag>
</#macro>

<#macro treetable id options>
    <@dataGridTag id=id options=options>
    <table id="${id}" class="easyui-treegrid" style="width: 100%;height: 100%;"
           data-options='${options}'>
        <thead>
        <tr>
            <#nested/>
        </tr>
        </thead>
    </table>
    </@dataGridTag>
</#macro>

<#macro table id options>
    <@dataGridTag id=id options=options>
    <table id="${id}" class="easyui-datagrid" style="width: 100%;height: 100%;"
           data-options='${options}'>
        <thead>
        <tr>
            <#nested/>
        </tr>
        </thead>
    </table>
    </@dataGridTag>
</#macro>

<#macro pageHeading>
<div class="page-heading">
    <ul class="breadcrumb">
        <#if parentMenuDetail??>
            <li>${parentMenuDetail.name}</li>
        </#if>
        <#if menuDetail??>
            <li class="active">${menuDetail.name}</li>
        </#if>
    </ul>
</div>
</#macro>


<#macro th options>
    <@dataGridTHTag options=options>
    <th data-options='${options}'><#nested/></th>
    </@dataGridTHTag>
</#macro>